﻿using System;

namespace DbMetadata
{
        /// <summary>
    /// Provides metadata information about a table column.
    /// </summary>
    [Serializable]    
    public class DbColumnInfo 
    {
        /// <summary>
        /// Sets or gets the <see cref="DbTableInfo"/> that is the owner of this column.
        /// </summary>
        /// <value></value>
        public DbTableInfo Table { get; set; }

        /// <summary>
        /// Sets or gets the name of the column.
        /// </summary>
        /// <value></value>
        public string ColumnName { get; set; }

        /// <summary>
        /// Sets or gets the .Net data type that should be used to represent the column value.
        /// </summary>
        /// <value></value>
        public Type DataType { get; set; }

        /// <summary>
        /// Gets or sets the ordinal positions of the column with a database table.
        /// </summary>
        /// <value></value>
        public int OrdinalPosition { get; set;}

        /// <summary>
        /// Gets or sets a value that determines if the column is nullable.
        /// </summary>
        /// <value></value>
        public bool IsNullable { get; set;}

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (ColumnName != null)
                return string.Format("{0} ({1})", ColumnName, DataType.Name);
            return base.ToString();
        }
    }
}

